package com.example.demo.config;

import com.aliyun.oss.OSSClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.File;

/**
 * OSS对象存储Demo
 *
 * @author vsalw
 */
@Controller
public class OSSCilentDemo {

    public Logger log = LoggerFactory.getLogger(this.getClass());


    @RequestMapping("/oss/up")
    @ResponseBody
    public void testUploadObject2OSS() {
        //上传文件
        OSSClient client = OSSConfig.getOSSClient();
        String flilePathName = "C:/TEMP/123.jpg";
        File file = new File(flilePathName);
        String diskName = "datas/image/";
        String md5key = OSSConfig.uploadObject2OSS(client, file, "vsalwtools", diskName, "image/jpg");
        log.info("上传后的文件MD5数字唯一签名:" + md5key);
    }

}
